//
//  WMWeight.h
//  WeightMaster
//
//  Created by sungeo on 15/8/14.
//  Copyright (c) 2015年 buddysoft. All rights reserved.
//

#import "iCloudModel.h"
#import "BDiCloudManager.h"
#import <UIKit/UIKit.h>

extern NSString * const WMWeightRecord;

typedef enum{
    WMWeightUnitKiloGram = 0,   // 公斤
    WMWeightUnitJin = 1,        // 斤
}WMWeightUnit;

typedef enum{
    WeightVersionCodeCreated = 0,       // 新创建体重对象的版本号
    WeightVersionCodeCached = 1,        // 缓存后体重对象的版本号
}WeightVersionCode;


@interface WMWeight : iCloudModel

/**
 *  体重值，默认单位：公斤
 */
@property (nonatomic, strong) NSNumber * value;

/**
 *  体重测量日期
 */
@property (nonatomic, strong) NSDate * measuringDate;

@property (nonatomic, copy) NSString * profileUUID;

@property (nonatomic, strong) UIImage * localProfileImage;

/**
 *  带参数初始化一个体重记录
 *
 *  @param value 体重值（公斤）
 *
 *  @return WMWeight 类型的体重记录对象
 */
- (instancetype)initWithValue:(NSNumber *)value;

- (instancetype)initFromiCloudRecordObject:(CKRecord *)record;

- (NSString *)weightUUID;

- (CKRecord *)convertToCKRecord;

- (void)packingCKRecord:(CKRecord *)record;

/**
 *  获取体重对应的照片对象，会一次尝试从本地缓存和从 CloudKit 中获取
 *
 *  @return profileImage 照片对象
 */
- (UIImage *)profileImage;

- (BOOL)isTheSameDayWith:(WMWeight *)weight;

- (BOOL)isEarlierThan:(WMWeight *)weight;

- (NSString *)monthAndDayString;


@end
